<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="材料" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script language="javascript">
	function doNew(){
		var url="/base/ProductNew.ihtm?type_id=${typeId}";
		parent.ShowIframeNoScroll("材料",url,900,400,"refreshProWin()",900,640);//refreshProWin是父窗口的
	}
	function refreshWin(){//父窗口的refreshProWin调用
		window.location="/base/ProductList.ihtm?"+getFromUrl();
	}
	function doEdit(id){
		var url="/base/ProductEdit.ihtm?id="+id;
		parent.ShowIframeNoScroll("材料",url,900,400,"refreshProWin()",900,640);//refreshProWin是父窗口的
	}
	function doDelete(id){
		parent.ShowConfirm('确认框','确定删除吗？',340,80,"doDelPro("+id+")");//doDelPro是父窗口的
	}
	function doDelAct(id){//是父窗口的doDelPro调用
		window.location="/base/ProductDelete.ihtm?id="+id+"&from_url="+encodeURIComponent(window.location);
	}
	function doSearch(){
		var typeId="${typeId}";
		var searchKey=encodeURIComponent(document.getElementById("search_key").value.trim());
		var searchAll="";
		if(document.getElementById("search_all").checked){
			searchAll="1";
		}
		window.location="/base/ProductList.ihtm?type_id="+typeId+"&search_key="+searchKey+"&search_all="+searchAll;
	}
	function doInit(){
		Window_Onload();
		document.getElementById("search_key").focus();
	}
	function checkSearchKey(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function DoubleClick(it){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		if(ob_arr.length>=it.getAttribute("index")){
			str=ob_arr[it.getAttribute("index")-1].value;
		}
		if(str==""){
			return;
		}
		doEdit(str);
	}
	function getMultiIds(){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		for (i=0;i<ob_arr.length;i++){
			if ((ob_arr[i].checked == true)){
				if(str!=""){
					str=str+";";
				}
				str = str+ob_arr[i].value;
			}
		}
		return str;
	}
	function doChangeType(){
		var ids=getMultiIds();
		if(ids==""){
			parent.ShowAlert('提示框','请选择要改类别的材料',200,100);
		}else{
			var strFeatures = "dialogWidth:350px;dialogHeight:210px;scroll:no;center:yes;status:no";
			var url="/base/ProductChangeTypeForm.ihtm?id_str="+ids;
			parent.ShowIframeNoScroll("修改类别",url,340,210,"refreshProWin()");//refreshProWin是父窗口的
		}
	}
	function getFromUrl(){
		var searchKey=encodeURIComponent("<c:out value="${searchKey}" />");
		var str="type_id=${typeId}&search_key="+searchKey+"&search_all=${searchAll}";
		return str;
	}
	function doDownload(expoType){
		window.location="/base/ProductList.ihtm?content_type=EXCEL&expo_type="+expoType+"&"+getFromUrl();
	}
	function doUpload(){
		parent.ShowIframeNoScroll("导入Excel","/base/ProductUploadForm.ihtm",560,300,"doUploadCallBack()");//doUploadCallBack是父窗口的
	}
	function doUploadCallBackExt(fileName){
		document.getElementById("LoadProcess").style.top=getTopPos(document.getElementById("search_key"))+50+"px";
		document.getElementById("LoadProcess").style.left=getleftPos(document.getElementById("search_key"))+100+"px";
		document.getElementById("LoadProcess").style.display="";

		var url="/base/ProductImport.ihtm?file_name=" + encodeURIComponent(fileName);
		var xmlHttp=createXMLHttpRequest();
		xmlHttp.open("GET", url, true);
		xmlHttp.onreadystatechange = function(){
			if (xmlHttp.readyState == 4) {
	      		if (xmlHttp.status == 200) {
		      		window.location=window.location;
	      		}
	      	}
	    };
	    xmlHttp.send(null);
	}
</script>
</head>
<body oncontextmenu="return false" onload="doInit();" scroll="no" style="background: #EAFAFF;">
		<div id="scrollDiv" style="OVERFLOW:auto;height:508px">
		  <div class="main search-business">
			   <div class="cue-info">
					<h4>
						<c:if test="${searchAll=='1'}">所有类别 - 材料</c:if>
						<c:if test="${searchAll!='1'}">${productType.typeName} - 材料</c:if>
					</h4>				   	
			  </div>
			  <div class="content">
			  	<table width="100%">
			      <tbody>
			        <tr>
			          <td width="130">
			          	<input type="text" class="TextBox" style="width:120px" id="search_key" name="search_key" onKeyUp="checkSearchKey();"  value="${searchKey}" title="以产品名称、产品名称拼音字头进行模糊查询">
					  </td>
			          <td style="text-align:right">
					  	<input type="button" class="buttom search-but" value=" 查 询" onClick="doSearch();" title="以产品名称、产品名称拼音字头进行模糊查询">		
						<input type="button" class="buttom search-add" value=" 新 增" onClick="doNew();">
						<input type="button" class="buttom search-remo" value="改类别" onClick="doChangeType();">
						<input type="button" class="buttom search-out" value=" 盘点表" onClick="doDownload('PD');" <c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';NO_EXPO;')!=-1}">disabled="true"</c:if>>
						<input type="button" class="buttom search-out" value=" 导 出" onClick="doDownload('CL');" <c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';NO_EXPO;')!=-1}">disabled="true"</c:if>>
					  </td>
			        </tr>
			        <tr>
			        	<td colspan="2">
			        		<input type="checkbox" id="search_all" name="search_all" <c:if test="${searchAll=='1'}">checked</c:if>>在所有类别中查找材料
			        	</td>
			        </tr>
			      </tbody>
			    </table>
			  </div>			  
			  <%@include file="../inc/AlertMsg.jsp"%>
			  <div class="table-list" style="width:97%; padding:15px 0 15px 10px; float:left;">
						<table width="100%">
							<tr>
								<th width="14"><input type="checkbox" onClick="javascript:checkall(this);"></th>
								<th width="15%">类别</th>
								<th width="13%" >材料编号</th>
								<th width="24%" >品名规格</th>
								<th width="10%" >计量单位</th>
								<th width="20%" >备注</th>
								<th width="18%" >操作</th>
							</tr>
							<c:forEach var="item" items="${productList}" varStatus="i">
							<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
							<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
							<tr class="${trClass}" index="${i.index+1}" style='cursor:pointer;' onmouseout='javascript:mouseout(this)' ondblclick='javascript:DoubleClick(this)' onmouseover='javascript:mouseover(this)' onClick='javascript:ClickCheck(this,true)'>
								<td><input type="checkbox" onClick="javascript:ClickCheck(this,true);" name='query_checkbox' value="${item[0]}"></td>
								<td>${item[7]}</td>
								<td>${item[1]}</td>
								<td>${item[2]}</td>
								<td>${item[3]}</td>
								<td>${item[6]}</td>
								<td>
									<a href="javascript:doEdit('${item[0]}');">编辑</a>
									<c:if test="${item[4]!=null && item[4]!=''}"><a href="${item[4]}" target="_blank">图片</a></c:if>
									<a href="javascript:doDelete('${item[0]}');">删除</a>
								</td>
							</tr>
							</c:forEach>
						</table> 
			  </div>
			</div>
		</div>
<%@ include file="../inc/LoadingDiv.jsp"%>
</body>
</html>